package com.lancer.dynamic.thread.pool;

import com.lancer.dynamic.thread.pool.config.ThreadPoolConfig;
import com.lancer.dynamic.thread.pool.controller.MonitorController;
import com.lancer.dynamic.thread.pool.service.ThreadPoolServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(ThreadPoolConfig.class)
public class DynamicThreadPoolAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public ThreadPoolManage threadPoolManager(ThreadPoolConfig properties) {
        return new ThreadPoolManage(properties);
    }

    @Bean
    @ConditionalOnMissingBean
    public ThreadPoolServiceImpl threadPoolServiceImpl(ThreadPoolManage threadPoolManage) {
        return new ThreadPoolServiceImpl(threadPoolManage);
    }
    @Bean
    @ConditionalOnMissingBean
    public MonitorController monitorController() {
        return new MonitorController();
    }
    @Bean
    @ConditionalOnMissingBean
    public ThreadPoolMonitor threadPoolMonitor() {
        return new ThreadPoolMonitor();
    }


}